package org.leetcode.easy;

import org.junit.Test;

import java.util.HashSet;

public class ContainsDuplicate {
    public boolean containsDuplicate(int[] nums) {
        HashSet<Integer> set = new HashSet<>();
        for (int e : nums) {
            if(set.contains(e)) {
                return true;
            } else {
                set.add(e);
            }
        }
        return false;
    }
    @Test
    public void test() {
        System.out.println(containsDuplicate(new int[]{1, 2, 3, 4}));
    }
}
